/* Filename: primer0.c
 * Description: 单进程计算区间内素数
 * Last modified: humble 20200322 17:05
 */
#include <stdio.h>
#include <stdlib.h>

#define LEFT (30000000)
#define RIGHT (30000200)

static void usage(void);

int main(int argc, char **argv) {
    if(argc != 1){ fprintf(stderr, "argc !=1"); usage(); exit(1); }
    int mark;
    for(int i = LEFT; i < RIGHT; i++) {
        mark = 1;
        for(int j = 2; j < i/2; j++) {
            if(i % j == 0){ mark = 0; break; } // 能被整除就不是素数
        }
        if(mark == 1){ printf("%d is a primer\n", i); }
    }
    return 0;
}

static void usage(void) {
#define USAGE "Usage:\n\
  Helloworld\n"
    printf(USAGE);
}
